package com.ld.hpfs.service.impl;

import java.util.ArrayList;
import java.util.HashMap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ld.hpfs.dao.PersonalMapper;
import com.ld.hpfs.service.PersonalService;
@Service
public class PersonalServiceImpl implements PersonalService {
	@Autowired
	private PersonalMapper personalMapper;
	private static final Logger logger = LoggerFactory.getLogger(DealServiceImpl.class);
	@Override
	public ArrayList<HashMap<String,Object>> getPersonalImage(HashMap<String,Object> param){
		return personalMapper.getPersonalImage(param);
	}
	
	@Override
	public int SavePersonalImage(HashMap<String,Object> param){
		try{
			int Num = personalMapper.getPersonalImageCount(param);
			if(Num > 0){
				personalMapper.SavePersonalImage(param);
			}else{
				personalMapper.SaveAndCreatePersonalImage(param);
			}
			return 0;
		}catch (Exception ex){
			ex.printStackTrace();
			logger.error(ex.getMessage());
			return -1;
		}
	}
	
	@Override
	public ArrayList<HashMap<String,Object>> FindSystemAndUser(HashMap<String,Object> param){
		return personalMapper.FindSystemAndUser(param);
	}

	@Override
	public int setModifyPassword(HashMap<String, Object> param) {
		try{
			String origin = personalMapper.getOriginPassword(param);
			if(origin.equals(param.get("origin"))){
				personalMapper.setModifyPassword(param);
				return 0;
			}else{
				return 2;
			}
		}catch (Exception ex){
			return -1;
		}
	}
}
